package com.zzyl.nursing.controller.member;

import cn.hutool.db.PageResult;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.nursing.dto.DeviceDto;
import com.zzyl.nursing.dto.FamilyMemberElderDto;
import com.zzyl.nursing.dto.QueryDeviceDataDto;
import com.zzyl.nursing.service.IFamilyMemberElderService;
import com.zzyl.nursing.vo.FamilyMemberElderVo;
import com.zzyl.nursing.vo.FamilyMemberVo;
import com.zzyl.nursing.vo.QueryDeviceDataVo;
import com.zzyl.nursing.vo.health.PropertyStatusInfoVoList;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客户家属健康管理Controller
 * @author wys
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "客户家属健康管理")
public class MemberUserController extends BaseController {
    @Autowired
    private IFamilyMemberElderService familyMemberElderService;

    /**
     * 绑定家人
     */
    @PostMapping("/add")
    @ApiOperation("绑定家人")
    public AjaxResult addFamilyMember(@RequestBody FamilyMemberElderDto familyMemberElderDto){
        familyMemberElderService.addFamilyMemberElder(familyMemberElderDto);
        return success();
    }

    /**
     * 查询家人列表
     */
    @GetMapping("/my")
    @ApiOperation("查询家人列表")
    public R<List<FamilyMemberElderVo>> my(){
        List<FamilyMemberElderVo> familyMemberElderVoList = familyMemberElderService.listFamilyMemberElder();
        return R.ok(familyMemberElderVoList);
    }

    /**
     * 分页查询
     *
     * @param pageNum
     * @param pageSize
     * @return cn.hutool.db.PageResult<java.util.List<?>>
     */
    @GetMapping("/list-by-page")
    @ApiOperation("查看已绑定家人列表（分页查询）")
    public R<PageResult<FamilyMemberVo>> list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize)
    {
        return R.ok(familyMemberElderService.getFamilyMemberElderList(pageNum, pageSize));
    }

    /**
     * 按天统计查询指标数据
     *
     */
    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public R<List<QueryDeviceDataVo>> queryDeviceDataListByDay(QueryDeviceDataDto queryDeviceDataDto)
    {
        return R.ok(familyMemberElderService.queryDeviceDataListByDay(queryDeviceDataDto));
    }


    /**
     * 按周统计查询指标数据
     *
     */
    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public R<List<QueryDeviceDataVo>> queryDeviceDataListByWeek(QueryDeviceDataDto queryDeviceDataDto)
    {
        return R.ok(familyMemberElderService.queryDeviceDataListByWeek(queryDeviceDataDto));
    }
    /**
     * 查询健康数据
     * @param deviceDto
     * @return com.zzyl.common.core.domain.R<java.util.List<com.zzyl.nursing.vo.DevicePropertyStatusVo>>
     */
    @PostMapping("/QueryDevicePropertyStatus")
    @ApiOperation("查询健康数据")
    public R<PropertyStatusInfoVoList> selectHealthy(@RequestBody DeviceDto deviceDto) {
        PropertyStatusInfoVoList propertyStatusInfoVo = familyMemberElderService.selectHealthy(deviceDto);
        return R.ok(propertyStatusInfoVo);
    }

}
